package com.peng._06interceptor.config;

import com.peng._06interceptor.interceptor.MyInterceptor1;
import com.peng._06interceptor.interceptor.MyInterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author peng
 * @Date 2024-04-28 11:34
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //策略1：拦截所有请求
//        registry.addInterceptor(new MyInterceptor1());
        registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/user/**")
                .excludePathPatterns("/user/login");
        registry.addInterceptor(new MyInterceptor2())
                .addPathPatterns("/user/**")
                .addPathPatterns("/user/login");
    }
}
